package tools

import (
	"bytes"
	"encoding/json"
	"io/ioutil"
	"log"
	"net/http"
)

func SendGet(url string) ([]byte, error) {
	// 将data转换为json字节数组
	jsonData, err := json.Marshal(nil)
	if err != nil {
		log.Println("jsonData error:", err)
		return nil, err
	}

	// 创建http请求
	req, err := http.NewRequest("GET", url, bytes.NewBuffer(jsonData))
	if err != nil {
		log.Println("NewRequest error:", err)
		return nil, err
	}

	// 发送请求
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		log.Println("Do error:", err)
		return nil, err
	}
	defer resp.Body.Close()

	// 读取响应内容
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		log.Println("body error:", err)
		return nil, err
	}

	return body, nil
}
